package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.*;
import cn.gson.fengboot.model.service.ZcontractService;
import cn.gson.fengboot.model.service.ZorderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/heton")
public class ZcontractController {
    @Autowired
    ZcontractService ddservice;

    //订单弹出框查询方法
    @RequestMapping("/list_ht")
    @ResponseBody
    public Map<String,Object> hetonlist(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.hetonlist(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //根据商机ID查询报价详情信息
    @RequestMapping("/bj_xq")
    @ResponseBody
    public List<DofferdetailsHt> allpro(Integer sjid){
        return ddservice.allpro(sjid);
    }

    //订单弹出框查询方法
    @RequestMapping("/list_ht2")
    @ResponseBody
    public Map<String,Object> hetonlist2(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.hetonlist2(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //订单弹出框查询方法
    @RequestMapping("/list_dd2")
    @ResponseBody
    public Map<String,Object> kaipiao2(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        ddservice.ddlist2(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    /*根据合同ID查询合同详情所有产品信息*/
    @RequestMapping("/list_htxqcp")
    @ResponseBody
    public List<Zcontractdetails> allpro(String search){
        return ddservice.allpro(search);
    }

    //新增
    @RequestMapping("/add_heton")
    @ResponseBody
    public void add(@RequestBody Zcontract ht){
        System.out.println(ht);
        ddservice.add(ht);
    }
}
